﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using NovinMedia.Data;

namespace NovinMedia.Data.Layer
{
    [DataObject(true)]
    public class PhieuNhapKho
    {
		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectAll()
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
 
                };
            return dbo.RunProcedure("pr_PhieuNhapKho_SelectAll", parameters, "PhieuNhapKho");
        }

		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectRow(string MaPhieuNhap)
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
					new SqlParameter("MaPhieuNhap",MaPhieuNhap) 
                };
            return dbo.RunProcedure("pr_PhieuNhapKho_SelectRow", parameters, "PhieuNhapKho");
        }

		[DataObjectMethod(DataObjectMethodType.Insert)]
		public int InsertRow(string MaPhieuNhap,string KhoHang,DateTime NgayPhieu,string MaNV)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaPhieuNhap",MaPhieuNhap),
					new SqlParameter("KhoHang",KhoHang),
					new SqlParameter("NgayPhieu",NgayPhieu),
					new SqlParameter("MaNV",MaNV) 
				};
			Result = dbo.RunProcedure("pr_PhieuNhapKho_Insert", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Update)]
		public int UpdateRow(string MaPhieuNhap,string KhoHang,DateTime NgayPhieu,string MaNV)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaPhieuNhap",MaPhieuNhap),
					new SqlParameter("KhoHang",KhoHang),
					new SqlParameter("NgayPhieu",NgayPhieu),
					new SqlParameter("MaNV",MaNV) 
				};
			Result = dbo.RunProcedure("pr_PhieuNhapKho_Update", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Delete)]
		public int DeleteRow(string MaPhieuNhap)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaPhieuNhap",MaPhieuNhap) 
				};
			Result = dbo.RunProcedure("pr_PhieuNhapKho_DeleteRow", parameters, out RowsAffected);
			return Result;
        }
    }
}